<?php

namespace App\Admin\Renderables;

use App\Admin\Actions\Delete;
use App\Logics\Logic;
use App\Models\AdminUser;
use App\Models\DyBaseInfo;
use App\Models\DyLd;
use App\Models\DyXfzdy;
use App\Models\DzzInfo;
use App\Models\DzzYjdzzInfo;
use App\Models\Role;
use App\Models\SpecialNode;
use App\Models\User;
use App\Policies\Admin\AdminPolicy;
use Dcat\Admin\Admin;
use Dcat\Admin\Grid;
use Dcat\Admin\Grid\LazyRenderable;
use Dcat\Admin\Widgets\Tooltip;

class DyLdRenderTable extends LazyRenderable
{
    public function grid(): Grid
    {
        $admin_user = AdminUser::find(Admin::user()->id);
        $sql = isset($this->payload['sql']) ? $this->payload['sql'] : '';
        $sql = $sql ? encrypt_decode($sql) : '';
        $builder = Logic::getBaseQuery(DyLd::query(), $admin_user, false);
        if($sql){
            $builder->whereRaw($sql);
        }

        $grid = Grid::make($builder, function (Grid $grid) {
            $grid->column('name');
            $grid->column('sex', '性别');
            $grid->column('rylb','人员类别');
            $grid->column('gzgw','工作岗位');
            $grid->column('csrq','出生年月');
            $grid->column('jrsj','入党时间');
            $grid->column('lcsj','流出年月');
            $grid->column('lrd','流入地');
            $grid->column('ldyy','流动原因');
            $grid->column('lx','联系方式');
            $grid->disableActions();
            $grid->setDialogFormDimensions('700px', '750px');
            $grid->disableCreateButton();
        });
        $grid->disableActions()->disableFilter()->disableCreateButton()->disableRowSelector();
        $grid->paginate(10);
        return $grid;
    }
}